import numpy as np
from matplotlib import pyplot as plt

from utils import analyze


def F(x):
    """
    目标函数

    :param x: 输入
    :return: 函数输出
    """
    return x * np.sin(10 * np.pi * x) + 1.0


if __name__ == '__main__':
    import matplotlib
    matplotlib.use("TkAgg")
    fig = plt.figure()
    ax1 = fig.add_subplot(121)
    ax2 = fig.add_subplot(122)
    print("GA:")
    analyze("info_GA.pkl", "x_list_GA.pkl", "y_list_GA.pkl", 1.850547466, ax1, F)
    print("SA:")
    analyze("info_SA.pkl", "x_list_SA.pkl", "y_list_SA.pkl", 1.850547466, ax2, F)
    plt.show()
